﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SD.IDAL;
using SD.Entities;
using System.Data.SqlClient;
using System.Data;

namespace SD.DAL
{
    public class ProgrammeDAO : BaseDAO, IProgrammeDAO
    {
        #region IProgrammeDAO Members

        /// <summary>
        /// Get the list of programme
        /// </summary>
        /// <param name="includeInactive">includeInactive parammeter</param>
        /// <returns>Return the list of programme</returns>
        public List<Programme> GetAll(Boolean includeInactive)
        {
            try
            {
                // Create command object
                SqlCommand comm = CreateCommand();
                // Add store procedure
                comm.CommandText = "ProgrammeGetAll";
                // Add parammeter
                comm.Parameters.AddWithValue("@includeInactive", includeInactive);

                DataTable dt = ExecuteSelectCommand(comm);
                List<Programme> list = new List<Programme>();
                Programme p = null;
                foreach (DataRow row in dt.Rows)
                {
                    p = new Programme();
                    p.ProgrammeId = row["ProgrammeId"].ToString();
                    p.Name = row["Name"].ToString();
                    p.Description = row["Description"].ToString();
                    p.Contact = row["ContactID"] == DBNull.Value ? null : new ContactDAO().GetById(row["ContactID"].ToString());
                    p.IsActive = Boolean.Parse(row["IsActive"].ToString());

                    list.Add(p);
                }
                return list;
            }
            catch (SqlException ex)
            {

                throw ex;
            }
        }

        public List<SD.Entities.Programme> GetByOrgID(string orgId)
        {
            throw new NotImplementedException();
        }

        public SD.Entities.Programme GetById(string programmeId)
        {
            throw new NotImplementedException();
        }

        public bool Insert(SD.Entities.Programme programme)
        {
            throw new NotImplementedException();
        }

        public bool Update(SD.Entities.Programme programme)
        {
            throw new NotImplementedException();
        }

        public bool Delete(string programmeId)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
